<template>
	<view class="center">
		<view class="logo" @click="goLogin" :hover-class="userInfo.length==0 ? 'logo-hover' : ''">
			<image class="logo-img" :src="userInfo.length!=0 ? userInfo.userHimg :defaultHead"></image>
			<view class="logo-title">
				<text class="uer-name">Hi，{{userInfo.length!=0? userInfo.userName : '您未登录'}}</text>
				<text class="go-login navigat-arrow" v-if="userInfo.length==0">&#xe65e;</text>
			</view>
		</view>
		<view class="center-list">
			<view class="center-list-item border-bottom">
				<text class="list-icon">&#xe60f;</text>
				<text class="list-text">帐号和安全</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item">
				<text class="list-icon">&#xe639;</text>
				<text class="list-text">用户反馈</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
		</view>
		<view class="center-list">
			<view class="center-list-item border-bottom">
				<text class="list-icon">&#xe60b;</text>
				<text class="list-text">帮助和用户引导</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item border-bottom">
				<text class="list-icon">&#xe65f;</text>
				<text class="list-text">服务条款及隐私</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item border-bottom">
				<text class="list-icon">&#xe614;</text>
				<text class="list-text">关于应用</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item border-bottom">
				<text class="list-icon">&#xe614;</text>
				<text class="list-text">检查更新</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
		</view>
		<view class="quite" v-show="userInfo.length!=0" @click="logout">
			<text class="quite_text">注销用户</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: [],
				defaultHead: '../../static/head.jpg'
			}
		},
		onShow() {
			console.log("onload.....")
			uni.getStorage({
					key: 'userInfo',
					success: (res) => {
						var that = this;
						that.userInfo = res.data;
						console.log(res.data)
					},
					fail: function() {
						console.log("获取失败")
						
					}
				})
		},
		methods: {
			goLogin() {
				console.log(this.userInfo.length);
				if (this.$data.userInfo.length==0) {
					console.log("点击前往登录")
					uni.navigateTo({
						url: "login"
					})
				} else {
					console.log("进入个人中心")
					uni.navigateTo({
						url: "myInfo"
					})
				}
			},
			logout() {
				uni.removeStorage({
					key: 'userInfo',
					success: function() {
						console.log('清除用户信息成功');
					},
					complete() {
						this.userInfo = []
					}
				});
				uni.reLaunch({
					url: '/pages/my/my'
				});
			}
		}
	}
</script>

<style>
	@import url("my.css");
</style>
